import socketio

sio = socketio.Client()


@sio.event
def connect():
    print('connection established')
# When a client wants to communicate with
# the server it emits an event.


@sio.event()
# =@on('my_message')
def my_message(data):
    print('get server message received with ', data)
    # sio.emit('my_data', {'response': 'my response'})


@sio.event
def disconnect():
    print('disconnected from server')


sio.connect('http://localhost:5001')  # ,namespaces=['/data'])
print("my sid is ", sio.sid)
sio.emit('my_data', {'response': 'my response'})
# sio.emit('my_email', {'response': 'my response'},namespace="/data")
sio.wait()
